package content;

import java.io.FileOutputStream;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;

import com.opensymphony.xwork2.ActionSupport;

public class ModifyXml extends ActionSupport {

	private String filename;
	private String id;
	private String parentid;
	private String type;
	private String viewtype;
	private String tabindex;
	private String image;
	private String color;
	private String navihide;
	private String navibackgroundimage;
	private String navibackgroundcolor;
	private String navitext;
	private String navitextcolor;
	private String navitextshadowcolor;
	private String navisize;
	private String navibackbutton;
	private String navibackbuttonimage;
	private String menubarshow;
	private String subtabshow;
	
	
	
	private FileOutputStream fos;
	

	public String execute() throws Exception {
		try {
			Element root = new Element("pageview");
			Element fiE = new Element("pageviewcontroller");
			fiE.setAttribute("id", String.valueOf(getId()));
			fiE.setAttribute("parentid", String.valueOf(getParentid()));
			fiE.setAttribute("type", String.valueOf(getType()));
			fiE.setAttribute("viewtype", String.valueOf(getViewtype()));
			fiE.setAttribute("tabindex", String.valueOf(getTabindex()));
			fiE.setAttribute("image", String.valueOf(getImage()));
			fiE.setAttribute("color", String.valueOf(getColor()));
			fiE.setAttribute("navihide", String.valueOf(getNavihide()));
			fiE.setAttribute("navibackgroundimage", String.valueOf(getNavibackgroundimage()));
			fiE.setAttribute("nabibackgroundcolor", String.valueOf(getNavibackgroundcolor()));
			fiE.setAttribute("navitext", String.valueOf(getNavitext()));
			fiE.setAttribute("navitextcolor", String.valueOf(getNavitextcolor()));
			fiE.setAttribute("navitextshadowcolor", String.valueOf(getNavitextshadowcolor()));
			fiE.setAttribute("navisize", String.valueOf(getNavisize()));
			fiE.setAttribute("navibackbutton", String.valueOf(getNavibackbutton()));
			fiE.setAttribute("navibackbuttonimage", String.valueOf(getNavibackbuttonimage()));
			fiE.setAttribute("menubarshow", String.valueOf(getMenubarshow()));
			fiE.setAttribute("subtabshow", String.valueOf(getSubtabshow()));

			root.setContent(fiE);

			Document doc = new Document(root);
			XMLOutputter xmlOut = new XMLOutputter();
			Format format = Format.getPrettyFormat();
			xmlOut.setFormat(format);
			fos = new FileOutputStream("c:/" + getFilename() + ".xml");
			xmlOut.output(doc, fos);
			new InputXml(getFilename());
		
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			fos.close();
		}
		return SUCCESS;
	}

	public String getFilename() {
		return filename;
	}


	public void setFilename(String filename) {
		this.filename = filename;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public String getParentid() {
		return parentid;
	}


	public void setParentid(String parentid) {
		this.parentid = parentid;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}


	public String getViewtype() {
		return viewtype;
	}


	public void setViewtype(String viewtype) {
		this.viewtype = viewtype;
	}


	public String getTabindex() {
		return tabindex;
	}


	public void setTabindex(String tabindex) {
		this.tabindex = tabindex;
	}


	public String getImage() {
		return image;
	}


	public void setImage(String image) {
		this.image = image;
	}


	public String getColor() {
		return color;
	}


	public void setColor(String color) {
		this.color = color;
	}


	public String getNavihide() {
		return navihide;
	}


	public void setNavihide(String navihide) {
		this.navihide = navihide;
	}


	public String getNavibackgroundimage() {
		return navibackgroundimage;
	}


	public void setNavibackgroundimage(String navibackgroundimage) {
		this.navibackgroundimage = navibackgroundimage;
	}


	public String getNavibackgroundcolor() {
		return navibackgroundcolor;
	}


	public void setNavibackgroundcolor(String navibackgroundcolor) {
		this.navibackgroundcolor = navibackgroundcolor;
	}


	public String getNavitext() {
		return navitext;
	}


	public void setNavitext(String navitext) {
		this.navitext = navitext;
	}


	public String getNavitextcolor() {
		return navitextcolor;
	}


	public void setNavitextcolor(String navitextcolor) {
		this.navitextcolor = navitextcolor;
	}


	public String getNavitextshadowcolor() {
		return navitextshadowcolor;
	}


	public void setNavitextshadowcolor(String navitextshadowcolor) {
		this.navitextshadowcolor = navitextshadowcolor;
	}


	public String getNavisize() {
		return navisize;
	}


	public void setNavisize(String navisize) {
		this.navisize = navisize;
	}


	public String getNavibackbutton() {
		return navibackbutton;
	}


	public void setNavibackbutton(String navibackbutton) {
		this.navibackbutton = navibackbutton;
	}


	public String getNavibackbuttonimage() {
		return navibackbuttonimage;
	}


	public void setNavibackbuttonimage(String navibackbuttonimage) {
		this.navibackbuttonimage = navibackbuttonimage;
	}


	public String getMenubarshow() {
		return menubarshow;
	}


	public void setMenubarshow(String menubarshow) {
		this.menubarshow = menubarshow;
	}


	public String getSubtabshow() {
		return subtabshow;
	}


	public void setSubtabshow(String subtabshow) {
		this.subtabshow = subtabshow;
	}


	
}
